<template>
	<div class="warp shareMain">
		<open-app ref="openApp"></open-app>
        <p class="header"><a  href="javascript:void(0)" @click="back()"><i></i></a>美式精品牛排</p>
		<div class="banner">
			<a href="javascript:;" @click="openApp"><img src="../assets/images/banner.jpg"></a>
		</div>

		<div class="show">
			<img :src="firstImage|imgDomain">
		</div>

		<div class="showTitle">
			<p class="p1">{{goods.name}}</p>
			<p class="p2">{{$t('message.currency')}} {{goods.price|toDecimal}}</p>
		</div>

		<div class="about shareItem">
			<p class="shartTitle">商品详情</p>
			<div class="info" v-html="goods.mobileDescription?goods.mobileDescription:'暂无'"></div>
		</div>

		<div class="show">
			<img src="../assets/images/footer.jpg">
		</div>
	</div>
</template>
<script>
import openApp from './OpenApp'
export default {
	components: {
		openApp
	},
	data () {
		return {
			goods: {},
			firstImage: '',
			status: false,
			productUID: this.$route.query.productUID, //商品ID
			salesOutletUID: this.$route.query.salesOutletUID ? this.$route.query.salesOutletUID : null //店铺ID
		}
	},
	created () {
		this.getGoods()
	},
	methods: {
		getGoods () {
			if (this.status) return true;
			if (!this.productUID) {
				alert("该连接无效");
				return false;
			}
			this.$http.post('/api/getGoods', { productUID: this.productUID }).then(res => {
				const data = res.data;
				if (data.resData) {
					this.goods = data.resData
					this.firstImage = this.goods.productPictures[0]
					this.status = true;
				} else {
					alert(data.description)
				}
			}, res => {

			})
		},
		openApp () {
			let shareOptions = [
				{ 'field': 'productUID', 'value': this.productUID },
				{ 'field': 'salesOutletUID', 'value': this.salesOutletUID },
			]
			this.$refs.openApp.openApp(shareOptions, 'goods');
		},
		back () {
			if (history.length >= 3) {
				this.$router.back()
			}/*  else {
				this.$router.push({ name: 'Register', query: {salesOutletUID: this.salesOutletUID} })
			} */
		}
	},
	filters: {
		// 补全图片路径
		imgFilter (val) {
			let url = 'http://imgnew.e-gatenet.cn/' + val
			return url
		},
		toDecimal (x) {
			var f = parseFloat(x)
			if (isNaN(f)) {
				return false
			}
			var f = Math.round(x * 100) / 100;
			var s = f.toString()
			var rs = s.indexOf('.')
			if (rs < 0) {
				rs = s.length
				s += '.'
			}
			while (s.length <= rs + 2) {
				s += '0';
			}
			return s;
		}
	}
}
</script>
<style scoped>
@charset "utf-8";

/* 样式重置 */
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
font,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend {
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  font-size: 100%;
  background: transparent;
  color: #474747;
  font-family: 'MicrosoftYaHei';
}
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
input,
textarea {
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  color: #474747;
  font-family: 'MicrosoftYaHei';
}
body {
  line-height: 1.5;
}
ol,
ul,
li {
  list-style: none;
}
blockquote,
q {
  quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
  content: '';
  content: none;
}
:focus {
  outline: 0;
}
ins {
  text-decoration: none;
}
del {
  text-decoration: line-through;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
  background-color: #fff;
}
a {
  cursor: pointer;
  text-decoration: none;
  color: #9b9b9b;
}
img {
  vertical-align: bottom;
}
i {
  font-style: normal;
  color: #666;
}
input[type='text'] {
  -webkit-appearance: none;
}
textarea {
  -webkit-appearance: none;
}
a,
img,
button,
input,
textarea,
label,
div {
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0);
}
/* 单独的清除元素*/
.clear {
  clear: both;
  display: block;
  overflow: hidden;
  visibility: hidden;
  width: 0;
  height: 0;
}

/* 当一个外部元素内部有浮动元素时，外部元素如需清除浮动，用如下的清除样式 */
.clearfix:after {
  clear: both;
  content: '.';
  display: block;
  visibility: hidden;
  height: 0;
}
.clearfix {
  display: inline-block;
}
* html .clearfix {
  height: 1%;
}
.clearfix {
  display: block;
}
* + html .clearfix {
  min-height: 1%;
}

body,
html {
  background: #f0f0f0;
  height: 100%;
}

.warp {
  width: 100%;
  max-width: 750px;
  position: relative;
  margin: auto;
  background: #f0f0f0;
}

.shareMain .header {
  text-align: center;
  font-size: 0.36rem;
  color: #181818;
  line-height: 0.8rem;
  position: relative;
  background: #fff;
}
.shareMain .header a {
  position: absolute;
  left: 0;
  top: 0;
  height: 0.8rem;
  width: 0.8rem;
}
.shareMain .header a i {
  width: 0.18rem;
  height: 0.34rem;
  background: url('../assets/images/back.png') no-repeat;
  background-size: 100%;
  display: block;
  margin: auto;
  margin-top: 0.23rem;
}

.shareMain .banner img {
  width: 100%;
}
.shareMain .title {
  position: relative;
  padding: 0.4rem;
  padding-left: 1.8rem;
}
.shareMain .title img {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  position: absolute;
  left: 0.5rem;
}
.shareMain .title .p1 {
  font-size: 0.3rem;
  color: #181818;
  line-height: 0.5rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.shareMain .title .p2 {
  font-size: 0.28rem;
  color: #555555;
  line-height: 0.5rem;
}
.shareMain .time ul {
  padding: 0 0.26rem;
  overflow: hidden;
  margin-bottom: 0.2rem;
}
.shareMain .time ul li {
  font-size: 0.28rem;
  color: #181818;
  line-height: 0.88rem;
  border-bottom: #e1e1e1 solid 0.01rem;
}
.shareMain .time ul li:last-child {
  border-bottom: none;
}
.shareMain .time ul li span {
  float: right;
}
.shareMain .about .info {
  font-size: 0.26rem;
  color: #666666;
  padding: 0.26rem;
}
.shareMain .info img {
  width: 100%;
}
.shareMain img {
  width: 100%;
}

.shareMain .address {
  padding: 0.24rem 0;
  position: relative;
  font-size: 0.28rem;
  min-height: 0.6rem;
}
.shareMain .address .add {
  color: #181818;
  padding-left: 0.7rem;
  padding-right: 1.2rem;
  line-height: 0.5rem;
}
.shareMain .address .add i {
  width: 0.28rem;
  height: 0.32rem;
  background: url('../assets/images/address.png') no-repeat;
  background-size: 100%;
  display: block;
  position: absolute;
  margin-left: -0.4rem;
  top: 0.34rem;
}
.shareMain .address .tel {
  position: absolute;
  right: 0;
  top: 50%;
  width: 1.1rem;
  height: 0.6rem;
  border-left: #ddd solid 0.01rem;
  margin-top: -0.3rem;
}
.shareMain .address .tel a {
  display: block;
  height: 0.48rem;
  padding-top: 0.12rem;
}
.shareMain .address .tel i {
  width: 0.36rem;
  height: 0.37rem;
  background: url('../assets/images/tel.png') no-repeat;
  background-size: 100%;
  display: block;
  margin: auto;
}

.shareMain .sell .shartTitle {
  padding-left: 0.82rem;
  position: relative;
}
.shareMain .sell .shartTitle i {
  width: 0.34rem;
  height: 0.34rem;
  background: url('../assets/images/share.png') no-repeat;
  background-size: 100%;
  display: block;
  position: absolute;
  left: 0.3rem;
  top: 0.26rem;
}
.shareMain .sell ul {
  padding: 0 0.3rem;
}
.shareMain .sell ul li {
  position: relative;
  padding: 0.2rem 0;
  padding-left: 1.2rem;
  border-bottom: #e1e1e1 solid 0.01rem;
}
.shareMain .sell ul li:last-child {
  border-bottom: none;
}
.shareMain .sell ul li img {
  width: 1rem;
  height: 1rem;
  position: absolute;
  left: 0;
}
.shareMain .sell ul li .p1 {
  font-size: 0.26rem;
  color: #323232;
  line-height: 0.5rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.shareMain .sell ul li .p2 {
  font-size: 0.26rem;
  color: #09bebf;
  line-height: 0.5rem;
}
.shareMain .sell .more {
  text-align: center;
  line-height: 0.66rem;
  border-top: #e1e1e1 solid 0.01rem;
}
.shareMain .sell .more a {
  display: block;
  font-size: 0.22rem;
  color: #777777;
}

.shareMain .show {
  margin-top: 0.1rem;
}
.shareMain .show img {
  width: 100%;
}
.shareMain .showTitle {
  background: #fff;
  margin-bottom: 0.2rem;
  padding: 0.26rem 0.5rem;
}
.shareMain .showTitle .p1 {
  font-size: 0.3rem;
  color: #181818;
  line-height: 0.5rem;
}
.shareMain .showTitle .p2 {
  font-size: 0.28rem;
  color: #09bebf;
  line-height: 0.5rem;
}
.shareMain .shareItem {
  background: #fff;
  margin-bottom: 0.2rem;
}
.shareMain .shartTitle {
  font-size: 0.28rem;
  color: #181818;
  line-height: 0.88rem;
  padding-left: 0.26rem;
  border-bottom: #e1e1e1 solid 0.01rem;
}
</style>